<?php
function eStore_send_aweber_mail($list_name,$from_address,$cust_name,$cust_email)
{
	eStore_payment_debug('Preparing to send AWeber signup request email.',true);
    $subject = "Aweber Automatic Sign up email";
    $body    = "\n\nThis is an automatic email that is sent to AWeber for member signup purpose\n".
               "\nEmail: ".$cust_email.
               "\nName: ".$cust_name;

    if (get_option('eStore_use_wp_mail'))
    {    	
    	$pos = strpos($from_address, "<");
    	if ($pos !== false){
    		$from_address = eStore_get_string_between($from_address,"<",">");
    	}
    	eStore_payment_debug('Sending AWeber signup request email via WordPress mailing system. From email:'.$from_address,true);
		$headers = 'From: '.$from_address . "\r\n";
    	wp_mail($list_name, $subject, $body, $headers);
    	return true;
    }
    else
    {
    	eStore_payment_debug('Sending AWeber signup request email via eStore\'s mail script.',true);
    	$attachment = '';
       	if(@eStore_send_mail($list_name,$body,$subject,$from_address,$attachment))
       	{
       		eStore_payment_debug('Signup email request successfully sent to AWeber.',true);
            return true;
       	}
       	else
       	{
            return false;
       	} 
    }   
}

function eStore_send_notification_email($to_address, $subject, $body, $from_address, $attachment='')
{
    if (get_option('eStore_use_wp_mail'))
    {
        $headers = 'From: '.$from_address . "\r\n";
        wp_mail($to_address, $subject, $body, $headers);
        return true;
    }
    else
    {
       	if(@eStore_send_mail($to_address,$body,$subject,$from_address,$attachment))
       	{
            return true;
       	}
       	else
       	{
            return false;
       	}
    }
}
?>
